//
//  THFlowEarnHallCell.h
//  YJB
//
//  Created by 中电大维 on 2017/1/12.
//  Copyright © 2017年 YJB. All rights reserved.
//

#import <UIKit/UIKit.h>
UIKIT_EXTERN NSString *const flowEarnHallCellID;
@class THFlowEarnHallModel;
@interface THFlowEarnHallCell : UITableViewCell
@property(nonatomic,strong)UIImageView *iconImgView;
@property(nonatomic,strong)UILabel  *titleLab;
@property(nonatomic,strong)UILabel  *award;
@property(nonatomic,strong)UIButton *vipAwardBtn;
@property(nonatomic,strong)UILabel  *surplus;
@property(nonatomic,strong)UILabel *vipAward;
@property(nonatomic,strong)THFlowEarnHallModel *model;
@property(nonatomic,assign)CGFloat cellHeight;

@end

/*
//
//  THFlowEarnHallCell.m
//  YJB
//
//  Created by 中电大维 on 2017/1/12.
//  Copyright © 2017年 YJB. All rights reserved.
//

#import "THFlowEarnHallCell.h"
#import "THFlowEarnHallModel.h"

NSString *const flowEarnHallCellID = @"THFlowEarnHallCellID";
@implementation THFlowEarnHallCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        //self.backgroundColor = kUIColorFromRGB(0xffebe7);
        //self.backgroundColor = [UIColor colorWithRed:rand()%255/255.0 green:rand()%255/255.0 blue:rand()%255/255.0 alpha:1];
        [self cpcTest];
    }
    return self;
}
- (NSMutableAttributedString *)getAttributedString:(NSString *)front Middle:(NSString *)middle Behind:(NSString *)behind{
    
    NSMutableAttributedString *attr = [NSString attributedString:front fontColor:kUIColorFromRGB(0x666666) middle:middle middleColor:kUIColorFromRGB(0xff783c) behind:behind behindColor:kUIColorFromRGB(0xff783c) font:FONT(15)];
    return attr;
}

- (void)cpcTest
{
    self.iconImgView.image = Image(@"th_cpc_default_normal");
    self.titleLab.text = @"只要轻松点几下，钱就到手啦，亲还在等什么呢，赶紧点我吧...";
    //    self.award.text = @"普通奖励 3金币";
    [self.vipAwardBtn setTitle:@"奖励" forState:UIControlStateNormal];
    
    self.vipAward.text = @"18 金币";
    self.surplus.text = @"已做过8/10个";
    
    self.award.attributedText = [self getAttributedString:@"普通奖励" Middle:@"  " Behind:@"16 金币"];
    //    self.vipAwardBtn.titleLabel.attributedText = [self getAttributedString:@"奖励" Middle:@" " Behind:@"18金币"];
    
    //self.vipAwardBtn.attributedText = [self getAttributedString:@"普通奖励" Middle:@" " Behind:@"16金币"];
    
    //    self.vipAwardBtn.backgroundColor = [UIColor orangeColor];
    //    self.vipAwardBtn.imageView.backgroundColor = [UIColor yellowColor];
    //    self.vipAwardBtn.titleLabel.backgroundColor = [UIColor redColor];
    
    
}

-(UIImageView *)iconImgView
{
    if (!_iconImgView) {
        _iconImgView = [[UIImageView alloc] init];
        _iconImgView.image = Image(@"th_cpc_default_normal");
        [self addSubview:_iconImgView];
        [_iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).offset(10);
            make.left.equalTo(self.mas_left).offset(15);
            make.width.height.mas_equalTo(48);
        }];
    }
    return _iconImgView;
}

-(UILabel *)titleLab
{
    if (_titleLab == nil)
    {
        _titleLab = [[UILabel alloc]init];
        _titleLab.backgroundColor = [UIColor clearColor];
        _titleLab.font = [UIFont systemFontOfSize:16];
        _titleLab.numberOfLines = 2;
        _titleLab.textColor = kUIColorFromRGB(0x333333);
        [self addSubview:_titleLab];
        [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).offset(15);
            make.left.equalTo(self.iconImgView.mas_right).offset(15);
            make.right.equalTo(self.mas_right).offset(-15);
            make.height.mas_equalTo(40);
        }];
    }
    return _titleLab;
}

-(UILabel *)award
{
    if (_award == nil)
    {
        _award = [[UILabel alloc]init];
        _award.backgroundColor = [UIColor clearColor];
        _award.font = [UIFont boldSystemFontOfSize:15];
        _award.numberOfLines = 0;
        _award.textColor = kUIColorFromRGB(0x666666);
        [self addSubview:_award];
        NSString *award = [NSString stringWithFormat:@"普通奖励 3金币"];
        CGFloat awardWidth = [NSString widthForString:award UIfontSize:FONT(15) andHeight:15];
        [_award mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.surplus.mas_bottom).mas_offset(10);
            make.left.equalTo(self.titleLab.mas_left);
            make.width.mas_equalTo(awardWidth);
            make.height.mas_equalTo(20);
        }];
    }
    
    
    return _award;
}

-(UILabel *)surplus
{
    if (_surplus == nil)
    {
        _surplus = [[UILabel alloc]init];
        _surplus.font = FONT(14);
        _surplus.textColor = kUIColorFromRGB(0x666666);
        //        _surplus.textAlignment = NSTextAlignmentCenter;
        //        [_surplus.layer setMasksToBounds:YES];
        //        [_surplus.layer setCornerRadius:5.0];
        //        [_surplus.layer setBorderWidth:1];
        //        [_surplus.layer setBorderColor:kUIColorFromRGB(0xfa5f3c).CGColor];
        [self addSubview:_surplus];
        [_surplus mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLab.mas_left);
            make.height.mas_equalTo(15);
            make.top.equalTo(self.titleLab.mas_bottom).offset(15);
        }];
    }
    return _surplus;
}
- (UIButton *)vipAwardBtn
{
    if (!_vipAwardBtn) {
        _vipAwardBtn = [[UIButton alloc] init];
        [_vipAwardBtn setTitleColor:kUIColorFromRGB(0x666666) forState:UIControlStateNormal];
        _vipAwardBtn.titleLabel.font = FONT(15);
        _vipAwardBtn.adjustsImageWhenHighlighted = NO;
        [_vipAwardBtn setImage:Image(@"vip-(3)") forState:UIControlStateNormal];
        _vipAwardBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [self addSubview:_vipAwardBtn];
        [_vipAwardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.award.mas_centerY);
            //make.left.equalTo(self.award.mas_right).offset(5);
            make.left.equalTo(self.award.mas_right).offset(5);
            make.right.equalTo(self.mas_right).offset(-12);
            make.width.equalTo(self.award.mas_width);
            make.height.mas_equalTo(28);
        }];
        //_vipAwardBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0,0);
        //_vipAwardBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0,0);
        
        _vipAward = [[UILabel alloc] init];
        _vipAward.textColor = [UIColor colorWithHexString:@"ff783c"];
        _vipAward.font = FONT(15);
        [_vipAwardBtn addSubview:_vipAward];
        
        [_vipAward mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.bottom.mas_equalTo(0);
            make.left.mas_equalTo(53);
            make.right.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
        }];
        
    }
    return _vipAwardBtn;
}

-(void)setModel:(THFlowEarnHallModel *)model
{
    self.titleLab.text = model.sitename;
    //    self.award.attributedText = [self getAttributedString:@"普通奖励" Middle:@"  " Behind:[NSString stringWithFormat:@"%@ 金币",model.usergold_one]];
    //    self.vipAward.text = [NSString stringWithFormat:@"%@ 金币",model.vipgold_one];
    self.award.attributedText = [self getAttributedString:@"奖励" Middle:@"" Behind:[NSString stringWithFormat:@"888金币"]];
    self.vipAward.text = [NSString stringWithFormat:@"888金币"];
    
    
    
    //    self.vipAwardBtn.titleLabel.attributedText = [self getAttributedString:@"奖励" Middle:@"" Behind:[NSString stringWithFormat:@"888金币"]];
    [self.vipAwardBtn setTitle:@"奖励" forState:UIControlStateNormal];
    
    self.surplus.text = [NSString stringWithFormat:@"已做%@/%@个",model.complete_num,model.surflimit];
    
    NSString *urlString = model.surf_icon;
    if (![urlString hasPrefix:@"http"])
        urlString = [@"http://" stringByAppendingString:urlString];
    [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:Image(@"th_cpc_default_normal")];
    //    CGFloat title_height = [NSString heightForString:model.sitename fontSize:16 andWidth:TableCell_TitleWidth];
    //    title_height = title_height>48?48:title_height;
    //    title_height = title_height<26?15:title_height;
    [self.titleLab mas_updateConstraints:^(MASConstraintMaker *make) {
        //        make.height.mas_equalTo(title_height);
        make.height.mas_equalTo(model.titleHeight);
    }];
}

@end
*/
/*
 //
 //  THFlowEarnHallCell.m
 //  YJB
 //
 //  Created by 中电大维 on 2017/1/12.
 //  Copyright © 2017年 YJB. All rights reserved.
 //
 
 #import "THFlowEarnHallCell.h"
 #import "THFlowEarnHallModel.h"
 
 NSString *const flowEarnHallCellID = @"THFlowEarnHallCellID";
 @implementation THFlowEarnHallCell
 
 -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
 {
 if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
 {
 //self.backgroundColor = kUIColorFromRGB(0xffebe7);
 //self.backgroundColor = [UIColor colorWithRed:rand()%255/255.0 green:rand()%255/255.0 blue:rand()%255/255.0 alpha:1];
 [self cpcTest];
 }
 return self;
 }
 - (NSMutableAttributedString *)getAttributedString:(NSString *)front Middle:(NSString *)middle Behind:(NSString *)behind{
 
 NSMutableAttributedString *attr = [NSString attributedString:front fontColor:kUIColorFromRGB(0x666666) middle:middle middleColor:kUIColorFromRGB(0xff783c) behind:behind behindColor:kUIColorFromRGB(0xff783c) font:FONT(15)];
 return attr;
 }
 
 - (void)cpcTest
 {
 self.iconImgView.image = Image(@"th_cpc_default_normal");
 self.titleLab.text = @"只要轻松点几下，钱就到手啦，亲还在等什么呢，赶紧点我吧...";
 //    self.award.text = @"普通奖励 3金币";
 [self.vipAwardBtn setTitle:@"奖励" forState:UIControlStateNormal];
 
 self.vipAward.text = @"18 金币";
 self.surplus.text = @"已做过8/10个";
 
 self.award.attributedText = [self getAttributedString:@"普通奖励" Middle:@"  " Behind:@"16 金币"];
 //    self.vipAwardBtn.titleLabel.attributedText = [self getAttributedString:@"奖励" Middle:@" " Behind:@"18金币"];
 
 //self.vipAwardBtn.attributedText = [self getAttributedString:@"普通奖励" Middle:@" " Behind:@"16金币"];
 
 //    self.vipAwardBtn.backgroundColor = [UIColor orangeColor];
 //    self.vipAwardBtn.imageView.backgroundColor = [UIColor yellowColor];
 //    self.vipAwardBtn.titleLabel.backgroundColor = [UIColor redColor];
 
 
 }
 
 -(UIImageView *)iconImgView
 {
 if (!_iconImgView) {
 _iconImgView = [[UIImageView alloc] init];
 _iconImgView.image = Image(@"th_cpc_default_normal");
 [self addSubview:_iconImgView];
 [_iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
 make.top.equalTo(self.mas_top).offset(10);
 make.left.equalTo(self.mas_left).offset(15);
 make.width.height.mas_equalTo(48);
 }];
 }
 return _iconImgView;
 }
 
 -(UILabel *)titleLab
 {
 if (_titleLab == nil)
 {
 _titleLab = [[UILabel alloc]init];
 _titleLab.backgroundColor = [UIColor clearColor];
 _titleLab.font = [UIFont systemFontOfSize:16];
 _titleLab.numberOfLines = 2;
 _titleLab.textColor = kUIColorFromRGB(0x333333);
 [self addSubview:_titleLab];
 [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
 make.top.equalTo(self.mas_top).offset(15);
 make.left.equalTo(self.iconImgView.mas_right).offset(15);
 make.right.equalTo(self.mas_right).offset(-15);
 make.height.mas_equalTo(40);
 }];
 }
 return _titleLab;
 }
 
 -(UILabel *)award
 {
 if (_award == nil)
 {
 _award = [[UILabel alloc]init];
 _award.backgroundColor = [UIColor clearColor];
 _award.font = [UIFont boldSystemFontOfSize:15];
 _award.numberOfLines = 0;
 _award.textColor = kUIColorFromRGB(0x666666);
 [self addSubview:_award];
 NSString *award = [NSString stringWithFormat:@"普通奖励 3金币"];
 CGFloat awardWidth = [NSString widthForString:award UIfontSize:FONT(15) andHeight:15];
 [_award mas_makeConstraints:^(MASConstraintMaker *make) {
 make.top.equalTo(self.surplus.mas_bottom).mas_offset(10);
 make.left.equalTo(self.titleLab.mas_left);
 make.width.mas_equalTo(awardWidth);
 make.height.mas_equalTo(20);
 }];
 }
 
 
 return _award;
 }
 
 -(UILabel *)surplus
 {
 if (_surplus == nil)
 {
 _surplus = [[UILabel alloc]init];
 _surplus.font = FONT(14);
 _surplus.textColor = kUIColorFromRGB(0x666666);
 //        _surplus.textAlignment = NSTextAlignmentCenter;
 //        [_surplus.layer setMasksToBounds:YES];
 //        [_surplus.layer setCornerRadius:5.0];
 //        [_surplus.layer setBorderWidth:1];
 //        [_surplus.layer setBorderColor:kUIColorFromRGB(0xfa5f3c).CGColor];
 [self addSubview:_surplus];
 [_surplus mas_makeConstraints:^(MASConstraintMaker *make) {
 make.left.equalTo(self.titleLab.mas_left);
 make.height.mas_equalTo(15);
 make.top.equalTo(self.titleLab.mas_bottom).offset(15);
 }];
 }
 return _surplus;
 }
 - (UIButton *)vipAwardBtn
 {
 if (!_vipAwardBtn) {
 _vipAwardBtn = [[UIButton alloc] init];
 [_vipAwardBtn setTitleColor:kUIColorFromRGB(0x666666) forState:UIControlStateNormal];
 _vipAwardBtn.titleLabel.font = FONT(15);
 _vipAwardBtn.adjustsImageWhenHighlighted = NO;
 [_vipAwardBtn setImage:Image(@"vip-(3)") forState:UIControlStateNormal];
 _vipAwardBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
 [self addSubview:_vipAwardBtn];
 [_vipAwardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
 make.centerY.equalTo(self.award.mas_centerY);
 make.left.equalTo(self.award.mas_right).offset(5);
 make.right.equalTo(self.mas_right).offset(-12);
 make.width.equalTo(self.award.mas_width);
 make.height.mas_equalTo(28);
 }];
 _vipAwardBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0,0);
 
 _vipAward = [[UILabel alloc] init];
 _vipAward.textColor = [UIColor colorWithHexString:@"ff783c"];
 _vipAward.font = FONT(15);
 [_vipAwardBtn addSubview:_vipAward];
 
 [_vipAward mas_makeConstraints:^(MASConstraintMaker *make) {
 
 make.top.bottom.mas_equalTo(0);
 make.left.mas_equalTo(64);
 make.right.mas_equalTo(0);
 make.bottom.mas_equalTo(0);
 }];
 
 }
 return _vipAwardBtn;
 }
 
 -(void)setModel:(THFlowEarnHallModel *)model
 {
 self.titleLab.text = model.sitename;
 self.award.attributedText = [self getAttributedString:@"普通奖励" Middle:@"  " Behind:[NSString stringWithFormat:@"%@ 金币",model.usergold_one]];
 self.vipAward.text = [NSString stringWithFormat:@"%@ 金币",model.vipgold_one];
 //    self.award.attributedText = [self getAttributedString:@"普通奖励" Middle:@"  " Behind:[NSString stringWithFormat:@"888 金币"]];
 //    self.vipAward.text = [NSString stringWithFormat:@"888 金币"];
 [self.vipAwardBtn setTitle:@"奖励" forState:UIControlStateNormal];
 
 self.surplus.text = [NSString stringWithFormat:@"已做%@/%@个",model.complete_num,model.surflimit];
 
 NSString *urlString = model.surf_icon;
 if (![urlString hasPrefix:@"http"])
 urlString = [@"http://" stringByAppendingString:urlString];
 [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:Image(@"th_cpc_default_normal")];
 //    CGFloat title_height = [NSString heightForString:model.sitename fontSize:16 andWidth:TableCell_TitleWidth];
 //    title_height = title_height>48?48:title_height;
 //    title_height = title_height<26?15:title_height;
 [self.titleLab mas_updateConstraints:^(MASConstraintMaker *make) {
 //        make.height.mas_equalTo(title_height);
 make.height.mas_equalTo(model.titleHeight);
 }];
 }
 
 @end

 */
